"""
AI 分析结果数据模型
"""
from dataclasses import dataclass
from datetime import datetime
from typing import Optional, List, Dict, Any


@dataclass
class AIResult:
    """
    AI 分析结果数据模型
    """
    id: str
    comment_id: str
    response_text: str
    timestamp: datetime
    
    # 可选字段
    sentiment: Optional[str] = None
    keywords: List[str] = None
    confidence: float = 1.0
    metadata: Dict[str, Any] = None
    
    def __post_init__(self):
        """
        初始化后处理
        """
        if self.keywords is None:
            self.keywords = []
        if self.metadata is None:
            self.metadata = {}
    
    def __str__(self) -> str:
        """
        返回 AI 分析结果的字符串表示
        
        @return: AI 分析结果的字符串表示
        """
        return f"[{self.timestamp.strftime('%H:%M:%S')}] AI: {self.response_text}" 